#include "../include/protpant.h"
#include "../include/video.h"


static vid videobackupmem[NROW * NCOL];
static vid *videobackup = videobackupmem;
static int protpant_time = DEFAULT_PROTTIME;		/* Tiempo de screensaver */
static int timer_ticks = 0;			/* Ticks de reloj */
static int protpant_flag = 0;				/* Flag de screensaver */


void int_08() {

timer_ticks++;

	if( !protpant_flag)
	{
		
		if(timer_ticks == protpant_time * TIKSSEG ){
			protpantenable();
		}

	}
	else
	{
		printprot();
	} 
	
};

void setProtPantTime( int i){
protpant_time = i;
}

void printprot(){

/*Codigo que rellena con un color cuando se llena la pantalla y de mientras imprime en varios colores*/
	/*if (timer_ticks % (NROW * NCOL) == 0)
		clearScreen();
	setDefaultFormat(timer_ticks % 250);
	putchar(timer_ticks);*/
	
/*      solo cambia el fondo y deja un cursor*/	
	if (timer_ticks % 60 == 0)
		clearScreen();
	setDefaultFormat(timer_ticks % (TIKSSEG * 6) );
	
}

void protpantdisable(){
	if (protpant_flag == 1)
	{
		protpant_flag = 0;
		timer_ticks = 0;
		LoadVideo(videobackup);
	}
	else
	{
		timer_ticks = 0;
	}
}


void protpantenable(){
	protpant_flag = 1;
	saveVideo(videobackup);
	clearScreen();
}
